/*==============================================================*/
/* Database name:  PhysicalDataModel_1                          */
/* DBMS name:      Microsoft SQL Server 2000                    */
/* Created on:     2011-8-20 15:58:21                           */
/*==============================================================*/


/*==============================================================*/
/* Table: daydeal                                               */
/*==============================================================*/
create table daydeal (
   id                   char(32)             not null,
   code                 varchar(10)          not null,
   name                 varchar(100)         not null,
   DAY                  varchar(19)          not null,
   "OPEN"               float                null,
   HIGH                 float                null,
   LOW                  float                null,
   "CLOSE"              float                null,
   VOL                  float                null,
   riseWidth            float                null,
   dayNum               int                  null,
   VOLRiseWidth         float                null,
   constraint PK_DAYDEAL primary key  (id),
   constraint AK_CODE_DATA_DAYDEAL unique (code, DAY)
)
go


/*==============================================================*/
/* Table: dealrecord                                            */
/*==============================================================*/
create table dealrecord (
   id                   char(32)             not null,
   happenDate           char(10)             not null,
   happenTime           char(8)              not null,
   businessName         varchar(20)          null,
   stockCode            varchar(10)          null,
   stockName            varchar(100)         null,
   dealPrice            float                null,
   dealNum              int                  null,
   dealAmount           float                null,
   stockBalance         float                null,
   commissionCharge     float                null,
   stampTax             float                null,
   transferCharge       float                null,
   otherCharge          float                null,
   happenCharge         float                null,
   fundsBalance         float                null,
   entrustCode          varchar(10)          null,
   entrustPrice         float                null,
   entrustNum           int                  null,
   stockholderCode      varchar(20)          null,
   fundsAccount         varchar(20)          null,
   moneyKind            varchar(20)          null,
   dealGroup            int                  null,
   constraint PK_DEALRECORD primary key  (id),
   constraint AK_DATE_TIME_DEALRECO unique (happenDate, happenTime)
)
go


/*==============================================================*/
/* Table: fiveminutedeal                                        */
/*==============================================================*/
create table fiveminutedeal (
   id                   char(32)             not null,
   code                 varchar(10)          null,
   name                 varchar(100)         null,
   dealdate             varchar(19)          null,
   dealtime             char(4)              null,
   startPrice           float                null,
   highestPrice         float                null,
   lowestPrice          float                null,
   endPrice             float                null,
   turnover             float                null,
   riseWidth            float                null,
   dayNum               int                  null,
   turnoverRiseWidth    float                null,
   constraint PK_FIVEMINUTEDEAL primary key  (id)
)
go


/*==============================================================*/
/* Table: industry                                              */
/*==============================================================*/
create table industry (
   id                   char(32)             not null,
   bkmc                 varchar(50)          not null,
   day                  char(10)             not null,
   week                 varchar(10)          not null,
   jzf                  float                null,
   qzf                  float                null,
   zcj                  varchar(20)          null,
   scb                  float                null,
   hsl                  float                null,
   sy_d                 float                null,
   lzgp                 varchar(50)          null,
   zgb                  varchar(10)          null,
   constraint PK_INDUSTRY primary key  (id)
)
go


/*==============================================================*/
/* Table: plate                                                 */
/*==============================================================*/
create table plate (
   id                   char(32)             not null,
   name                 varchar(50)          null,
   id_parent            char(32)             null,
   constraint PK_PLATE primary key  (id)
)
go


/*==============================================================*/
/* Table: plate_stock                                           */
/*==============================================================*/
create table plate_stock (
   id_plate             char(32)             not null,
   id_stock             char(32)             not null,
   constraint PK_PLATE_STOCK primary key  (id_plate, id_stock)
)
go


/*==============================================================*/
/* Table: risewidthResult                                       */
/*==============================================================*/
create table risewidthResult (
   id                   char(32)             not null,
   statisticsWidth      float                not null,
   statisticsDay        varchar(19)          not null,
   ADVANCE              int                  not null,
   DECLINE              int                  null,
   js                   int                  not null,
   constraint PK_RISEWIDTHRESULT primary key  (id)
)
go


/*==============================================================*/
/* Table: risewidthResultInfo                                   */
/*==============================================================*/
create table risewidthResultInfo (
   id                   char(32)             not null,
   code                 varchar(10)          not null,
   name                 varchar(100)         not null,
   day                  varchar(19)          not null,
   riseWidth            float                null,
   id_risewidthResult   char(32)             null,
   constraint PK_RISEWIDTHRESULTINFO primary key  (id)
)
go


/*==============================================================*/
/* Table: stock                                                 */
/*==============================================================*/
create table stock (
   id                   char(32)             not null,
   code                 varchar(10)          not null,
   name                 varchar(100)         not null,
   myflag               char(1)              null,
   bkmc                 varchar(50)          null,
   constraint PK_STOCK primary key  (id),
   constraint AK_AKS_STOCK unique (code)
)
go


alter table plate
   add constraint FK_PLATE_REFERENCE_PLATE foreign key (id_parent)
      references plate (id)
go


alter table plate_stock
   add constraint FK_PLATE_ST_REFERENCE_STOCK foreign key (id_stock)
      references stock (id)
go


alter table plate_stock
   add constraint FK_PLATE_ST_REFERENCE_PLATE foreign key (id_plate)
      references plate (id)
go


alter table risewidthResultInfo
   add constraint FK_RISEWIDT_RISEWIDTINFO foreign key (id_risewidthResult)
      references risewidthResult (id)
go


